﻿using System;
using System.Diagnostics;
using System.Linq;
using System.Text.Json;

namespace SelectANDSelectMany
{
    class Program
    {
        static void Main(string[] args)
        {
            //string[] text = { "Albert was here", "Burke slept late", "Connor is happy" };

            //var tokens = text.Select(s => s.Split(" "));

            //foreach (string[] line in tokens)

            //    foreach (string token in line)

            //        Console.Write("{0}.", token);



            //string[] text1 = { "Albert was here", "Burke slept late", "Connor is happy" };
            //var tokens1 = text1.SelectMany(s => {
            //    var char1 = s.ToCharArray();
            //    var char2 = char1[0];
            //    return new[] { char2};
            //});

            //foreach (var token in tokens1)

            //    Console.Write("{0}.", token);
            100.Times(() => {
                Console.WriteLine(1);
            
            });
            100.Times1(counter => {
                Console.WriteLine(counter*3);
            });
            Console.Read();
        }


    
    }

    public static class Extension 
    {
        public static void Times(this int count, Action action)
        {
            for (var counter = 0; counter < count; counter++)
            {
                action();
            }
        }

        public static void Times1(this int count, Action<int> action)
        {
            for (var counter = 0; counter < count; counter++)
            {
                action(counter);
            }
        }
    }
}
